home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
macros
/
latex209
/
contrib
/
misc
/
optarg.sty
< prev
next >
Wrap
Text File
|
1993-07-15
|
948b
|
43 lines
\def\newoptargcommand#1{%
\@ifnextchar({\@xoptargcmd{#1}}%
{\newcommand{#1}}%
}
\def\@xoptargcmd#1(#2){%
% \@ifdefinable#1%
% {
\expandafter\def\expandafter#1\expandafter{%
\expandafter
\@ifnextchar
\expandafter
[%
\csname\string#1\expandafter\endcsname
\expandafter
{\csname\string#1\endcsname[#2]}}%
\expandafter\@zoptargcmd
\csname\string#1\endcsname
}
\def\@zoptargcmd#1{%
\@ifnextchar[{\@zzoptargcmd#1}%
{\def#1[####1]}%
}
\catcode`\?=11\relax
\long\def\@zzoptargcmd#1[#2]#3{%
\@tempcnta#2\relax
\let#1\relax
\let\@?@\relax
\edef\@tempa{\long\def#1[\@?@1]}%
\@tempcntb \tw@
\@whilenum\@tempcnta>\z@
\do{%
\edef\@tempa{\@tempa\@?@\the\@tempcntb}%
\advance\@tempcntb \@ne
\advance\@tempcnta \m@ne}%
\let\@?@##%
\@tempa{#3}%
}
\catcode`\?=12\relax
\endinput